<!DOCTYPE html>
<html>
    
    <head>
        <title>系统工具</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <!-- Bootstrap -->
        <link href="View/FHL/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="View/FHL/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
        <link href="View/FHL/assets/styles.css" rel="stylesheet" media="screen">
        <link href="View/FHL/vendors/jGrowl/jquery.jgrowl.css" rel="stylesheet" media="screen">
        <!--[if lte IE 8]>
        <script language="javascript" type="text/javascript" src="vendors/flot/excanvas.min.js"></script><![endif]-->
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->

        <script src="View/FHL/vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
    </head>
    
    <body>
    {include h}
        <div class="container-fluid">
            <div class="row-fluid">
                {include l}
                <div class="span10" id="content">
                      <!-- morris stacked chart -->

                    <div class="row-fluid">
                        <div class="span6">
                            <!-- block -->
                            <div class="block">
                                <div class="navbar navbar-inner block-header">
                                    <div class="muted pull-left">后台更新</div>
                                </div>
                                <div class="block-content collapse in">

                                    <div class="span12">
                                        <h4 title="{$moreInfo}">本机特征码：{$realFCode} 授权日期：{$licDate}</h4>
                                        <input id="up_license_input" type='file' class='filebutton' style='display:none' onchange='fileSelected(this)'/>
                                        <input id="up_core_input" type='file' class='filebutton' style='display:none' onchange='fileSelected(this)'/>
                                        <input id="up_client_input" type='file' class='filebutton' style='display:none' onchange='fileSelected(this)'/>

                                            <button type="button" class="btn btn-large btn-block btn-primary" id="up_license">更新license</button>
                                            <button type="button" class="btn btn-large btn-block btn-danger" id="up_cc">更新系统软件</button>
                                            <button type="button" class="btn btn-large btn-block btn-warning" id="up_client">更新客户端软件</button>

                                    </div>
                                </div>
                            </div>
                            <!-- /block -->
                        </div>
                        <div class="span6">
                            <!-- block -->

                            <div class="block">
                                <div class="navbar navbar-inner block-header">
                                    <div class="muted pull-left">系统控制</div>
                                </div>
                                <div class="block-content collapse1 in">
                                    <button data-href="?set/shutdown.html"  class="btn btn-danger btn-large sysContral">关机</button>
                                    <button data-href="?set/restart.html"  class="btn btn-warning btn-large sysContral">重启</button>
                                    <a href="?setip.html" target="_blank"  class="btn btn-info btn-large tooltip-top"
                                       data-original-title="务必连接管理口后打开 http://192.168.1.1/setip.html">修改IP</a>
                                       <button data-href="?set/reset.html"  class="btn btn-inverse btn-large sysContral" 
                                       title="将删除文件加速链路以及日志" >重置</button>
                                </div>
                            </div>
                            <!-- /block -->
                        </div>
                        <div class="span6">
                            <!-- block -->
                            <div class="block">
                                <div class="navbar navbar-inner block-header">
                                    <div class="muted pull-left">用户管理</div>
                                </div>
                                <div class="block-content collapse in">
                                    <a class="btn btn-success btn-large disabled1" data-toggle="modal" data-target="#modalPass" href="#">修改密码</a>
                                </div>
                            </div>
                            <!-- /block -->
                        </div>

                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                            <!-- block -->
                            <div class="block">
                                <div class="navbar navbar-inner block-header">
                                    <div class="muted pull-left">网络测试</div>
                                </div>
                                <div class="block-content collapse1 in">
                                    <div style="margin-bottom: 10px">
                                        <label class="control-label" for="testIp" style="float: left;padding-top: 9px" >IP地址：</label>
                                        <input class="input-xlarge focused" id="testIp" style="float: left;margin-top: 5px"
                                               type="text" value="192.168.1.1">
                                        <button data-href="?set/shut.html"  style="margin-left: 10px" id="sysTestPing"
                                                        class="btn btn-success btn-large ">ping测试</button>
                                        <button data-href="?set/t.html"  style="margin-left: 10px" id="sysTestTarcert"
                                                class="btn btn-success btn-large sysTestTarcert">tracert测试</button>
                                                <button data-href="?set/t.html"  style="margin-left: 10px" id="sysTestCurl"
                                                class="btn btn-success btn-large sysTestCurl">curl测试</button>
                                    </div>
                                    <div style="margin-bottom: 10px">
                                        <label class="control-label" for="testIp" style="float: left;padding-top: 9px" >端 &nbsp 口：</label>
                                        <input class="input-xlarge focused" id="testPort" style="float: left;margin-top: 5px"
                                               type="text" value="2000">
                                        <button data-href="?set/port.html"  style="margin-left: 10px" id="sysTestPort"
                                                        class="btn btn-success btn-large ">占用查看</button>
                    
                                    </div>
                                    <div>
                                        <button data-href="?set/re.html"  style="clear: left" id="sysShowRoute"
                                                class="btn btn-warning btn-large sysTest">查看路由表</button>
                                        <button data-href="?set/re.html"  style="clear: left" id="sysShowNmcli"
                                                class="btn btn-warning btn-large sysTest">查看网口配置</button>
                                        <button data-href="?set/re.html"  style="clear: left" id="sysShowSpeed"
                                                class="btn btn-warning btn-large sysTest">查看网口速度</button>
                                    </div>
                                   
                                </div>
                            </div>
                            <!-- /block -->
                            <!-- 加速协议测试block -->
                            <div class="block">
                                <div class="navbar navbar-inner block-header">
                                    <div class="muted pull-left">加速协议测试</div>
                                </div>
                                <div class="block-content collapse1 in">
                                    <div style="margin-bottom: 10px">
                                        <label class="control-label" for="testFHLIp" style="float: left;padding-top: 9px" >IP地址：</label>
                                        <input class="input-xlarge focused" id="testFHLIp" style="float: left;margin-top: 5px"
                                               type="text" value="192.168.1.1">

                                        <label class="control-label" for="testFHLPort" style="float: left;padding-top: 9px;margin-left:10px" >端 &nbsp 口：</label>
                                        <input class="input-xlarge focused" id="testFHLPort" style="float: left;margin-top: 5px"
                                               type="text" value="6000">

                                        <button data-href=""  style="margin-left: 10px" id="sysFHLPing"
                                                        class="btn btn-success btn-large ">测试</button>
                                    </div>
                                </div>
                            </div>
                            <!-- /block -->
                            <!-- block -->
                            <div class="block">
                                <div class="navbar navbar-inner block-header">
                                    <div class="muted pull-left">系统时间</div>
                                </div>
                                <div class="block-content collapse1 in">
                                    <div style="margin-bottom: 10px">
                                        <label class="control-label" for="date" style="float: left;padding-top: 9px" >当前时间：</label>
                                        <input class="input-xlarge focused" id="date" style="float: left;margin-top: 5px"
                                               type="text" value="{$date}">
                                        <button   style="margin-left: 10px" id="setDate"
                                                class="btn btn-success btn-large ">修改
                                        </button>
                                        <button   style="margin-left: 10px" id="refreshNTP"
                                        class="btn btn-info btn-large ">同步NTP
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <!-- /block -->
                        </div>

                        <div id="sysTestModal" class="modal hide" style="width: 50%;
                        top: 50%;
                        left: 70%;
                        transform: translate(-50%, -50%);">
                            <div class="modal-header">
                                <button data-dismiss="modal" class="close" type="button">&times;</button>
                                <h3>测试反馈</h3>
                            </div>
                            <div class="modal-body" id="sysTestContent">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <hr>
            {include f}
        </div>
        <!--/.fluid-container-->
    <!--alert 确认-->
    <div id="modalPass" class="modal hide">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">&times;</button>
            <h3>修改密码</h3>
        </div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label" for="pass0">原始密码</label>
                <div class="controls">
                    <input class="input-xlarge focused" id="pass0" type="text" value="原始密码">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="pass1">新密码</label>
                <div class="controls">
                    <input class="input-xlarge focused" id="pass1" type="text" value="">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="pass2">确认新密码</label>
                <div class="controls">
                    <input class="input-xlarge focused" id="pass2" type="text" value="">
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <a data-dismiss="modal" class="btn btn-danger" href="#" id="setPass" >确认修改</a>
            <a data-dismiss="modal" class="btn" href="#">取消</a>
        </div>
    </div>
    <!--alert确认对话框-->

        <script src="View/FHL/vendors/jquery-1.9.1.min.js"></script>
        <script src="View/FHL/bootstrap/js/bootstrap.min.js"></script>

        <script src="View/FHL/vendors/jGrowl/jquery.jgrowl.js"></script>

        <script src="View/FHL/assets/scripts.js"></script>
        <script>
            var uploadURL="";

            function fileSelected(obj)
            {
                var fbutton = obj;//dom元素
                console.log(fbutton);
                //读取文件
                var reader = new FileReader();
                reader.onload = function(e)
                {
                    var dataURL = e.target.result;//'...(base64编码)...'
                    //alert(data);
                    var htmlImg = "<img src = '" + dataURL + "'/>";
                    $(".img").html(htmlImg);
                }
                var file = fbutton.files[0];
                reader.readAsDataURL(file);

                startFileUpload(file);
            }
            //开始上传
            function startFileUpload(file)
            {
                //手工构造一个form对象
                var formData = new FormData();
                formData.append("file" , file);// 'file' 为HTTP Post里的字段名, file 对浏览器里的File对象
                //手工构造一个请求对象，用这个对象发送表单数据
                //设置 progress, load, error, abort 4个事件处理器
                var request = new XMLHttpRequest();
                request.upload.addEventListener("progress" , window.evt_upload_progress , false);
                request.addEventListener("load", window.evt_upload_complete, false);
                request.addEventListener("error", window.evt_upload_failed, false);
                request.addEventListener("abort", window.evt_upload_cancel, false);
                request.open("POST", uploadURL ); // 设置服务URL
                request.send(formData);  // 发送表单数据
            }
            window.evt_upload_progress = function(evt)
            {
                if(evt.lengthComputable)
                {

                    var progress = Math.round(evt.loaded * 100 / evt.total);
                    console.log("上传进度" + progress);
                }
            };
            window.evt_upload_complete = function (evt)
            {
                if(evt.loaded == 0)
                {
                    console.log ("上传失败!");
                }
                else
                {
                    console.log ("上传完成!");
                    var response = JSON.parse(evt.target.responseText);
                    console.log (response);
                    $.jGrowl(response.info);
                   // window.location.reload();
                }
            };
            window.evt_upload_failed = function (evt)
            {
                console.log  ("上传出错");
            };
            window.evt_upload_cancel = function (evt)
            {
                console.log( "上传中止!");
            };
        $(function() {
            $('.tooltip').tooltip();
            $('.tooltip-left').tooltip({ placement: 'left' });
            $('.tooltip-right').tooltip({ placement: 'right' });
            $('.tooltip-top').tooltip({ placement: 'top' });

            $('#up_license').click(function(){
                uploadURL="?set/uploadfile?type=license"
                $("#up_license_input").click();
            });
            $('#up_cc').click(function(){
                uploadURL="?set/uploadfile?type=cc"
                $("#up_core_input").click();
            });
            $('#up_client').click(function(){
                uploadURL="?set/uploadfile?type=client"
                $("#up_client_input").click();
            });
            $('.sysContral').click(function (e) {
                $.post($(this).data("href"), {},  function(ee){
                    if(ee.error){
                        $.jGrowl(ee.info);
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#sysTestTarcert').click(function (e) {
                $.jGrowl("正在tracert。。。。。。");
                $.get("?set/showTracert?tip="+$('#testIp').val(), {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        for(var i in ee.info){
                            $('#sysTestContent').append("<pre>"+ee.info[i]+"</pre>");
                        }
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#sysTestCurl').click(function (e) {
                $.jGrowl("正在获取网页。。。。。。");
                $.get("?set/showCurl?tip="+$('#testIp').val(), {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        
                            $('#sysTestContent').append('<xmp>'+ee.info+'</xmp>');
                        
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#sysTestPing').click(function (e) {
                $.jGrowl("正在ping。。。。。。");
                $.get("?set/showPing?tip="+$('#testIp').val(), {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        for(var i in ee.info){
                            $('#sysTestContent').append("<pre>"+ee.info[i]+"</pre>");
                        }
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#sysFHLPing').click(function (e) {
                $.jGrowl("正在测试联通性......");
                $.get("?set/showFHLPing?tip="+$('#testFHLIp').val()+"&tport="+$('#testFHLPort').val(), {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        for(var i in ee.info){
                            $('#sysTestContent').append("<pre>"+ee.info[i]+"</pre>");
                        }
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#sysTestPort').click(function (e) {
                $.get("?set/showPort?port="+$('#testPort').val(), {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        for(var i in ee.info){
                            
                            $('#sysTestContent').append("<pre>"+ee.info[i]+"</pre>");
                        }
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#sysShowRoute').click(function (e) {
                $.get("?set/showRoute?", {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        for(var i in ee.info){
                            $('#sysTestContent').append("<pre>"+ee.info[i]+"</pre>");
                        }
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#sysShowNmcli').click(function (e) {
                $.get("?set/showNmcli?", {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        for(var i in ee.info){
                            $('#sysTestContent').append("<pre>"+ee.info[i]+"</pre>");
                        }
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            //显示网速
            $('#sysShowSpeed').click(function (e) {
                $.get("?set/showSpeed?", {},  function(ee){
                    if(ee.state){
                        $('#sysTestContent').empty();
                        for(var i in ee.info){
                            $('#sysTestContent').append("<pre>"+ee.info[i]+"</pre>");
                        }
                        $('#sysTestModal').modal('show')
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            //设置时间
            $('#setDate').click(function (e) {
                $.post("?set/setDate?", {
                    date:$('#date').val()
                },  function(ee){
                    if(ee.state){
                        $.jGrowl(ee.info);
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            //刷新NTP refreshNTP
            $('#refreshNTP').click(function (e) {
                $.post("?set/refreshNTP?", {
                    //date:$('#date').val()
                },  function(ee){
                    if(ee.state){
                        $.jGrowl(ee.info);
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });
            $('#setPass').click(function (e) {
                $.post("?set/setPass?", {
                    pass0:$('#pass0').val(),
                    pass1:$('#pass1').val(),
                    pass2:$('#pass2').val()
                },  function(ee){
                    if(ee.state){
                        $.jGrowl(ee.info);
                    }else{
                        $.jGrowl(ee.info);
                    }
                },'json');
            });


        });
        </script>
    </body>

</html>